home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / backbin.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  4KB  |  144 lines

  1. {$X+,B-,V-,S-,I-} {essential compiler directives}
  2.  
  3. Program Backbin; { as of 950301}
  4.  
  5. { Example for the nwBindry unit / NwTP 0.6 API. (c) 1994,1995 R.Spronk }
  6.  
  7. { Purpose: Backs up the bindery files to the a: drive. }
  8. {          You need to be supervisor-equivalent to run this. }
  9.  
  10. { Tests the following nwBindry calls:
  11.  
  12.   OpenBindery
  13.   CloseBindery
  14. }
  15.  
  16. Uses DOS,nwMisc,nwBindry;
  17.  
  18. Var BindSeq:byte;
  19.     myObjID:LongInt;
  20.     Version:word;
  21.     s      :string;
  22.  
  23. LABEL enable;
  24.  
  25. Procedure FileCopy(fn1,fn2:string);
  26. LABEL 1;
  27. Var f1,f2    :file;
  28.     buffer   :array[1..4096] of byte;
  29.     BytesRead:word;
  30. begin
  31. assign(f1,fn1);
  32. reset(f1,1);
  33. if ioresult<>0
  34.  then begin
  35.       writeln('Error opening input file:',fn1);
  36.       writeln('>> File wasn''t copied.');
  37.       goto 1;
  38.       end;
  39. assign(f2,fn2);
  40. rewrite(f2,1);
  41. if ioresult<>0
  42.  then begin
  43.       writeln('Error opening output file :',fn2);
  44.       writeln('>> File wasn''t copied.');
  45.       goto 1;
  46.       end;
  47. REPEAT
  48. BlockRead(f1,buffer[1],4096,BytesRead);
  49. BlockWrite(f2,buffer[1],BytesRead);
  50. UNTIL (BytesRead<4096);
  51. 1: ;
  52. close(f1);
  53. close(f2);
  54. {$I+}
  55. end;
  56.  
  57.  
  58. begin
  59. writeln('BACKBIN Test program for the nwBindry unit of the NwTP package.');
  60. writeln('-Backs up the bindery files to drive A');
  61. writeln;
  62.  
  63. IF NOT IsShellLoaded
  64.  then begin
  65.       writeln('Load network shell before executing this program.');
  66.       halt(1);
  67.       end;
  68.  
  69. { need supervisor privileges to run this test }
  70. GetBinderyAccessLevel(BindSeq,myObjId);
  71. if bindSeq<>(BS_SUPER_WRITE OR BS_SUPER_READ) { $33}
  72.  then begin
  73.       writeln('You need to be supervisor equivalent to run this program.');
  74.       halt(1);
  75.       end;
  76.  
  77. writeln;
  78. writeln('WARNING:');
  79. writeln('Continue this program ONLY WHEN:');
  80. writeln('-You are the only user logged in.');
  81. writeln('-No other users will login in next few minutes.');
  82. writeln('-You are running Netware 2.15c, 2.2 or 3.x');
  83. writeln('-A diskette with sufficient space is in the A drive.');
  84. writeln;
  85. writeln('-If you have doubts about any of the above points: PLEASE ABORT NOW');
  86. writeln('-This program was made for test purposes only.');
  87. writeln;
  88. write('Type Y <return> to continue, <return> to abort.');
  89. readln(s);
  90. if NOT ( s[1] IN ['y','Y'])
  91.  then begin
  92.       writeln('Program aborted..');
  93.       halt(1);
  94.       end;
  95.  
  96. {determine Advanced Netware version. }
  97. nwMisc.GetNWVersion(version);
  98.  
  99. if (Version<215) or (version>399)
  100.  then begin
  101.       writeln('This util only works with NW 2.15+ or 3.x');
  102.       writeln('The bindery files were NOT backed up.');
  103.       halt(1);
  104.       end;
  105. version:=(version DIV 100);
  106.  
  107. {Note for final version: make sure no users are logged in. (NwConn functions)}
  108. {Note for final version: disable user login (see nwServ) }
  109.  
  110. {close the bindery to backup the files..}
  111. IF NOT CloseBindery
  112.  then begin
  113.       writeln('Couldn''t close the bindery.');
  114.       writeln('The bindery files were NOT backed up');
  115.       writeln('Error : $',HexStr(NwBindry.Result,2));
  116.       goto enable;
  117.       end;
  118.  
  119. {back up the bindery files}
  120. if version=2
  121.  then begin
  122.       FileCopy('SYS:\SYSTEM\NET$BIND.SYS','A:\NET$BIND.OLD');
  123.       FileCopy('SYS:\SYSTEM\NET$BVAL.SYS','A:\NET$BVAL.OLD');
  124.       end
  125.  else begin {3.x}
  126.       FileCopy('SYS:\SYSTEM\NET$OBJ.SYS' ,'A:\NET$OBJ.OLD');
  127.       FileCopy('SYS:\SYSTEM\NET$PROP.SYS','A:\NET$PROP.OLD');
  128.       FileCopy('SYS:\SYSTEM\NET$VAL.SYS' ,'A:\NET$VAL.OLD');
  129.       end;
  130.  
  131. {open the bindery again}
  132. IF NOT OpenBindery
  133.  then begin
  134.       writeln('Couldn''t open the bindery after copying the bindery files.');
  135.       writeln('Error : $',HexStr(NwBindry.Result,2),' (',NwBindry.result,')');
  136.       end
  137.  else writeln('The bindery files were successfully backed up.');
  138.  
  139. {Note for final version: enable users to login (see nwServ) }
  140.  
  141. enable: ;
  142.  
  143. end.
  144.